﻿using Microsoft.Phone.Maps.Controls;
using Microsoft.Phone.Controls;
using System.Windows.Controls;
using System.Windows;

namespace WindowsPhone_Map_TTTN
{
    class MFactory
    {
        private static MainPage _mainpage;

        private static Map _map;

        private static MDb _db;

        /**
         * Set MainPage
         * */
        public static void setMainPage(MainPage value)
        {
            _mainpage = value;
        }
        /**
         * GetMap
         * */
        public static Map getMap()
        {
            if (_map == null)
            {
                _map = new Map();
                _map.Name = "osmmap";
                _mainpage.ContentPanel.Children.Add(_map); ;
            }
            return _map;
        }

        /**
        * Get main panel
        * */
        public static Grid getContentPanel()
        {
            return _mainpage.ContentPanel;
        }

        public static MDb getDb()
        {
            if (_db == null)
            {
                _db = new MDb();
            }
            return _db;
        }
        /**
         * 
         * */
        public static MapSocketUDP getSocketUDP()
        {
            return MapSocketUDP.getInstance();
        }

        public  static MapView getView()
        {
            return MapView.getInstance();
        }
    }
}
